package com.example.demo.service;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

import org.springframework.stereotype.Component;

import com.example.demo.model.Dto;

@Component
public class ServiceImpl2 implements Service2 {

	@Override
	public void processThis(Future<Dto> test, Service service) throws InterruptedException, ExecutionException {
		Integer a = null;
		System.out.println(a = test.get().getId());
		if (a % 2 == 0) {
			System.out.println("found even @ " + a + " now retrying");
			Thread.sleep(1234);
			service.test(new Dto((int) (System.nanoTime() % 1000000), "hi"));
			throw new RuntimeException();
		}
	}

}
